Attribute VB_Name = "xml"
Option Explicit

Private XMLDom As DOMDocument30 'Abre el documento XML
Private XMLNode As IXMLDOMNode 'Corresponde a cada elemento del xml
Private XMLNodeList As IXMLDOMNodeList 'Carga la lista de nodos xml

Public FileXML As String

Public Sub GetLabels(ByRef forma As Form)
    Dim Contador As Integer
    Dim control As control
    Dim XMLNodeItem As IXMLDOMNode
    
    Set XMLDom = New DOMDocument30
    If XMLDom.Load(FileXML) Then
               
        DoEvents
        Set XMLNode = XMLDom.childNodes(1).selectSingleNode(forma.Name)
        
     '   MsgBox XMLNode.selectSingleNode("txt1").Text
        
        
  
        If Not (XMLNode Is Nothing) Then
            forma.Caption = XMLNode.Attributes(0).Text 'Toma el valor del atributo del nodo de la ventana
           
            For Each control In forma.Controls
             
                Select Case UCase(TypeName(control))
                
                    Case "MENU": control.Caption = XMLNode.selectSingleNode(control.Name).Text
                    Case "TEXTBOX": control.Text = XMLNode.selectSingleNode(control.Name).Text
                    Case "LABEL": control.Caption = XMLNode.selectSingleNode(control.Name).Text
                   ' Case "COMMANDBUTTON":

                    'control.Caption = XMLNode.selectSingleNode(control.Name).Text

                    
                    
                End Select
            Next
        End If
    End If
End Sub

Public Sub GetLabelsTitulo(ByRef formulario As Form)
    Dim Contador As Integer
    Dim control As control
    Dim XMLNodeItem As IXMLDOMNode
    
    
    Set XMLDom = New DOMDocument30
    If XMLDom.Load(FileXML) Then
    DoEvents
        Set XMLNode = XMLDom.childNodes(1).selectSingleNode(formulario.Name)
   
              If Not (XMLNode Is Nothing) Then
              formulario.Caption = XMLNode.Attributes(0).Text
              End If
   
    
    End If
End Sub


Public Sub GetLabelsMenu(ByRef formulario As Form, texto As Menu)
    Dim Contador As Integer
    Dim control As control
    Dim XMLNodeItem As IXMLDOMNode
    
    Set XMLDom = New DOMDocument30
    If XMLDom.Load(FileXML) Then
    DoEvents
        Set XMLNode = XMLDom.childNodes(1).selectSingleNode(formulario.Name)
        
              If Not (XMLNode Is Nothing) Then
              
            button.Caption = XMLNode.selectSingleNode(texto.Name).Text
        End If
    End If
End Sub

Public Sub GetLabelsLabel(ByRef formulario As Form, texto As Label)
    Dim Contador As Integer
    Dim control As control
    Dim XMLNodeItem As IXMLDOMNode
    
    Set XMLDom = New DOMDocument30
    If XMLDom.Load(FileXML) Then
    DoEvents
        Set XMLNode = XMLDom.childNodes(1).selectSingleNode(formulario.Name)
        
              If Not (XMLNode Is Nothing) Then
              
            button.Caption = XMLNode.selectSingleNode(texto.Name).Text
        End If
    End If
End Sub

Public Sub GetLabelsButton(ByRef formulario As Form, button As CommandButton)
    Dim Contador As Integer
    Dim control As control
    Dim XMLNodeItem As IXMLDOMNode
    
    Set XMLDom = New DOMDocument30
    If XMLDom.Load(FileXML) Then
    DoEvents
        Set XMLNode = XMLDom.childNodes(1).selectSingleNode(formulario.Name)
        
              If Not (XMLNode Is Nothing) Then
              
            button.Caption = XMLNode.selectSingleNode(button.Name).Text
        End If
    End If
End Sub


Public Sub GetLabelsTextBox(ByRef formulario As Form, cajaTexto As TextBox)
    Dim Contador As Integer
    Dim control As control
    Dim XMLNodeItem As IXMLDOMNode
    
    Set XMLDom = New DOMDocument30
    If XMLDom.Load(FileXML) Then
    DoEvents
        Set XMLNode = XMLDom.childNodes(1).selectSingleNode(formulario.Name)
        
              If Not (XMLNode Is Nothing) Then
              
            button.Caption = XMLNode.selectSingleNode(cajaTexto.Name).Text
        End If
    End If
End Sub


